//传入文件大小，根据大小给出kb,m,gb单位的数值
export const getFileSize = (_size: any) => {
    const size = parseInt(_size)
    if (size < 1024 * 1024) {
        return (size / 1024).toFixed(2) + " KB";
    } else if (size < 1024 * 1024 * 1024) {
        return (size / 1024 / 1024).toFixed(2) + " MB";
    } else {
        return (size / 1024 / 1024 / 1024).toFixed(2) + " GB";
    }
}

//传入文件日期，返回文件剩余天数
export const getFileRemainingDays = (date: any) => {
    let now = new Date();
    let fileDate = new Date(date);
    let remainingDays = (fileDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24);
    let day = remainingDays > 1 ? remainingDays.toFixed(0) : 1
    return day + "天";
}

//传入文件日期，返回文件是否有效
export function getFileStatus(date) {
    let now = new Date();
    let fileDate = new Date(date);
    return fileDate.getTime() > now.getTime();
}
